home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Comms Spectacular / AppleTalk Remote Access / Telebit T3000⁄WBlazer V.32bis / Telebit T3000_WBlazer V.32bis
Encoding:
Text File  |  1994-09-08  |  27.8 KB  |  666 lines

  1. ! Version 1.0.4 12/20/92
  2. ! "Telebit T3000/WorldBlazer Modem (V.32bis) 6/4/92" JFK
  3. ! Adapted from the Telebit T3000 script
  4. ! "Telebit T3000 Modem 11/11/91" JFK
  5. ! 11/14/91 JFK - Added a ton o' comments...
  6. ! 11/23/91 JFK - Cleaned up comments a little bit more,
  7. !                and added S11=50.
  8. ! 12/2/91  JFK - Took S11 back out.
  9. ! 12/9/91  JFK - Added the pinouts for the RTS/CTS cable to the comments
  10. !                Since you have to make a hardware handshaking cable.
  11. ! 1/16/92  JFK - Add a bunch more comments about the cable.
  12. ! 3/30/92  JFK - Added comments about the hang up sequence.
  13. ! 3/31/92  JFK - Added sbreak in hangup sequence to speed things up.
  14. ! 3/31/92  JFK - Added S38=3 to help ensure that the modem will be
  15. !                able to transmit all the data in its buffer (including
  16. !                the disconnect command for the remote modem!) before
  17. !                it hangs up.
  18. ! 4/2/92   JFK - Changed S38 to 255.  See notes below.
  19. ! 4/2/92   JFK - Changed S51 to 254 in hang up sequence since 19200 is
  20. !                our DTE speed.
  21. ! 6/4/92   JFK - I actually forgot to set S51 to 254 on 4/2.  It's done
  22. !                now
  23. ! 6/4/92   JFK - Added Short break and 1/2 second pause in label
  24. !                64.  Apparently the WorldBlazer's command mode
  25. !                is not as robust as the T3000, so this step
  26. !                is done to ensure the modem will respond to commands
  27. !                after it is hung up.  If it is not, the script will
  28. !                not be able to configure the modem to answer the telephone.
  29. !                Also, if label 64 does not receive an "OK", loop back
  30. !                up to the top of the hangup sequence (label 60) and try again.
  31. ! 6/12/92  JFK - Began to test Turbo PEP stuff.
  32. ! 6/13/92  JFK - Configured modem to not use Turbo-PEP.  This is due to the 
  33. !                poor performance ARA obtains with Turbo-PEP's half-duplex
  34. !                design. 
  35. ! 8/19/92  JFK - Added Q0 in label 5 and label 30 for Rackmount modems.
  36. !                Changed escape  sequence back to "+++" for the original
  37. !                T3000 modem with LA3.00 ROM's.  This script should now
  38. !                be able to work with the Telebit T3000 and WorldBlazer
  39. !                in V.32bis mode (Up to ROM version LA5.00W).  It should
  40. !                also function  correctly on rackmount units.
  41. ! 8/23/92  JFK - Moved Q0 from label 5 to label 4.  Also added S2=128 to 
  42. !                disable the escape sequence, and removed the escape sequence
  43. !                code from label 61.  This allows for the possibility of the 
  44. !                data having a TIES pattern in it.
  45. ! 8/31/92  JFK - Version 1.0.2.  Added a short break at the beginning of the 
  46. !                connect sequence.  It would appear that the LA5.XX ROM's need
  47. !                to be coaxed into command mode.  Also added logic in hangup
  48. !                label to exit if the modem is turned off before the computer.
  49. !                This will take awhile, but it should exit (rather than loop
  50. !                forever).
  51. ! 9/22/92  JFK - Version 1.0.3d1.  Changed S51=252 in label 64
  52. ! 9/27/92  JFK - Added flush after short break in label 61 to clear out the
  53. !                "OK" when the modem returns to command mode.
  54. ! 9/27/92  JFK - Added S51=252 in label 5.  This allows the modem the hangup
  55. !                sequence to work without extranous short breaks to set
  56. !                the baud rate.
  57. ! 9/28/92  JFK - Re-added a short break and pause in label 63, before the 
  58. !                AT&F9.
  59. ! 10/5/92  JFK - Called it 1.0.3.
  60. ! 11/19/92 JFK - Began playing with RTS hardware handshaking.
  61. ! 12/6/92  JFK - Went alpha.  Mainly cleaned up comments.
  62. ! 12/20/92 JFK - Called it 1.0.4.
  63. !  Note the cable requirements when using a V.32bis modem.  Since a lot
  64. !  of people do not have this cable, you should not use this approach when
  65. !  scripting for V.32 or slower modems.
  66. !
  67. ! Cable needed to use AppleTalk Remote Access with V.32bis modems:
  68. !   Din-8    DB-25
  69. ! 1 (DTR)   4,20 (RTS, DTR)
  70. ! 2 (CTS)   5 (CTS) *
  71. ! 3 (TxD-)  2 (TD)
  72. ! 4 (SG)    7 (SG)
  73. ! 5 (RxD-)  3 (RD)
  74. ! 6 (TxD+)  Not Connected
  75. ! 7 (GPi)   8 (DCD)
  76. ! 8 (RxD+)  7 (SG)
  77. !  
  78. ! * Normally 2(CTS)<->6 (DSR) on other Macintosh cables.
  79. !
  80. !-  One consequence of using this cable is that DSR (or DCD) from the modem is  
  81. !   no longer connected to the Macintosh.  This does not let your Macintosh 
  82. !   communication software use the DSR (or DCD) signal to detect carrier loss.  
  83. !   And since the Macintosh Serial driver does not support the GPi input...you 
  84. !   are sort of stuck, unless your communications software does use the GPi 
  85. !   input.  Or Apple builds GPi support into the serial driver.
  86. !
  87. !-  Since DTR and RTS are connected together, there are 3 different configurations
  88. !   this cable can be used with:
  89. !
  90. !-  The modem must be configured to ignore DTR (usually the &D0 command) when
  91. !   using this cable with other communications applications.  Otherwise, when RTS
  92. !   handshaking from the Macintosh is used, the modem will drop connection the
  93. !   first time the Mac de-asserts RTS.
  94. !
  95. !-  If there is a need to use DTR to make the modem disconnect, RTS handshaking 
  96. !   cannot be used to control the flow of data from the modem to the Macintosh.  
  97. !   CTS handshaking (from the modem to the Macintosh) is available.  This is 
  98. !   what ARA does so it can force the modem to hang up, and at the same time 
  99. !   the modem can signal the Macintosh to stop sending data.  This assumes that 
  100. !   the Macintosh will always be able to accept data from the modem.  This will 
  101. !   not be true if the Macintosh is talking to the modem at 57.6KBps with 
  102. !   V.32bis & V.42Bis.  There will be times when the Macintosh will need to 
  103. !   signal the modem to stop sending data.
  104. !
  105. !-  RTS handshaking and DTR can be used  together with this cable if the
  106. !   handshaking behaviour is known, and DTR delay can be set on the modem.
  107. !   For example, some Hayes compatible modems allow the DTR delay to be set
  108. !   between 0-255 hundreds of a second (0-2.55 seconds, usually via the S25
  109. !   register).  If the maximum amount of time the computer will RTS handshake
  110. !   is less than 2.55 seconds, and the computer application can de-assert DTR
  111. !   for a variable length of time, then both RTS handshaking and DTR can be used.
  112. !
  113. !In summary, with this cable:
  114. !
  115. !If you want to use RTS hardware handshaking, you cannot use DTR to control the 
  116. !modem.  You will have to resort to other methods to coerce the modem to 
  117. !disconnect.
  118. !
  119. !If you want to control the modem with DTR, you cannot use RTS hardware 
  120. !handshaking so the Macintosh must be able to accept data from the modem at all 
  121. !times, or can recover if data is lost.
  122. !
  123. !If the modem's DTR delay can be set to a higher amount of time that the
  124. !longest possible RTS handshake, and the computer application can de-assert
  125. !DTR for a variable length of time, then both RTS handshaking and DTR can
  126. !be used.
  127. !
  128. !In all cases you can use CTS hardware handshaking so the modem can signal 
  129. !the Macintosh to discontinue sending data.
  130. !
  131. @ORIGINATE
  132. @ANSWER
  133. !
  134. ! Talk to the modem at 19,200 bps.  the T3000/WorldBlazer should auto-baud this
  135. ! unless the user has locked the port to a particular speed.  If it
  136. ! is locked to a different speed, the user will need to change that.
  137. !
  138. serreset 19200, 0, 8, 1
  139. !
  140. !  The idea here is to get the modem into a known state, and then change only 
  141. !  the registers that are necessary to support the connection.  Most of the 
  142. !  time AT&F will be sufficient, but some modems allow the user to change the 
  143. !  F0 parameters.  There isn't much that can be done to prevent this, but if 
  144. !  the modem has any pre-configured configurations, and one of them sets 
  145. !  hardware handshaking, use it.
  146. !
  147. ! Recall the factory configuration
  148. ! F9 is the built in pre-configured setting for CTS/RTS handshaking on the 
  149. ! T3000/WorldBlazer.  Since it's possible for the user to modify F0 parameters,
  150. ! this is a little safer.
  151. !
  152. ! AT&F9 sets:
  153. ! &C1 - DCD is on after connect
  154. ! &D2 - DTR on/off disconnects
  155. ! S48=0 - Strip the 8th bit off a character before comparing it to
  156. !         the value in S2.  If S2 is set to a number above 127, this
  157. !         allows the script to disable the escape sequence.  This is
  158. !         to allow for the possibility of the escape pattern (TIES)
  159. !         to be in the data stream.  Since the script uses a short
  160. !         break to enter command mode (S61), this should not be a problem.
  161. ! S58=2 - Use RTS/CTS flow control in full-duplex mode
  162. ! S61=1 - Go into command mode when receiving break from DTE (see
  163. !         @HANGUP for why the script cares about this).
  164. ! S181=1 - Turn *on* DTE <-> line buffering if there is no error control.
  165. !                            Since the modem will be talking to the Mac at 
  166. !                            19,200 bps no matter what speed it connects at, 
  167. !                            this needs to be on.
  168. !
  169. !  Every time the script needs to send commands to the modem, the strategy is:  
  170. !  Clear all matchstrings, look for specific responses, and loop around a 
  171. !  couple of times.  Later in the script, certain loops pause 50-70 seconds, 
  172. !  such as when the script dials a number and is waiting for a connection.  
  173. !  Other times, the script pauses 3-5 seconds and loops around. When the script 
  174. !  is sending commands to the modem, it should expect to see a response within 
  175. !  a couple of seconds, so it's best to look quickly and exit with an error in 
  176. !  a reasonable amount of time so the user does not wait a for a long time 
  177. !  before they are notified that they may need to power-cycle/reset the modem.  
  178. !  When the script is dialing out over a telephone system or PBX, it needs 
  179. !  enough time to make a connection.  In short, if it's communicating to a 
  180. !  modem, loop in 3-7 second increments.  If the script is waiting for 
  181. !  something other than a modem response (like a completed connection or 
  182. !  terminal server) it may need 60-70 seconds.
  183. !
  184. !  If the defaults cannot be set, jump down to label 59, which exits and asks 
  185. !  the user to check out the modem.  If the AT&F command can not be accepted, 
  186. !  the modem may be hung and needs to be manually reset.
  187. !
  188. settries 0
  189. matchclr
  190. @LABEL 1
  191. !
  192. ! It appears that LA5.01 ROM's do not autobaud if another application has left
  193. ! the modem in an inconsistant state, so send a short break and then pause
  194. ! a half second to allow the modem enter command mode (or reset autobaud).
  195. !
  196. Sbreak
  197. pause 5
  198. matchstr 1 4 "OK\13\10"
  199. write "AT&F9\13"
  200. matchread 30
  201. inctries
  202. iftries 2 59
  203. !
  204. ! Modem is not responding, so de-assert DTR and send a break to try to reset it.
  205. !
  206. DTRClear
  207. pause 30
  208. DTRSet
  209. SBreak
  210. jump 1
  211. !
  212. !  The script was able to get the modem into a default factory state.  Now 
  213. !  set the basic hardware type configuration such as command echo, hardware 
  214. !  handshaking, and DTR control.  If the &F9 command had not set up handshaking 
  215. !  this is where it would be done.  It's not desirable to create one long 
  216. !  command string with everything on it because some modems cannot handle a 
  217. !  long command string, and long strings are harder to debug.  It's easy
  218. !  to enter an incorrect S-register value.  For the most part, the following 
  219. !  commands are probably common across a lot of modems, but always look up the 
  220. !  commands in the modem manual.
  221. !
  222. ! Next, Set up the configuration: drop connection after losing DTR
  223. ! Turn off auto answer and command echo, and configure the modem to
  224. ! return result codes for both local and remote modems.  Also configure
  225. ! the modem to basically ignore any type of escape sequence to command
  226. ! mode except a short break.  This is done in case a TIES type escape
  227. ! escape sequence is in the data stream.  Finally, configure the modem to
  228. ! wait for 2.55 seconds before recognizing DTR.
  229. !
  230. ! &D3 - DTR off/on resets modem 
  231. ! S0=0 - Don't answer calls
  232. ! E0 - Turn command echo off
  233. ! Q0 - Return result codes for both local and remote modems.  &F9 sets this
  234. !      only for standalone modems, but it has to be done here in case the
  235. !      script is being used with a rackmount modem.
  236. ! S2=128 - Set the escape character to ASCII 128.  When this is done
  237. !          and S48 is set to 0 (&F9 did that), the modem will ignore
  238. !          the TIES escape sequence.
  239. ! S25=255 - DTR needs to be de-asserted for 2.55 seconds before the
  240. !           modem recognizes it.
  241. @LABEL 4
  242. pause 5
  243. matchclr
  244. matchstr 1 5 "OK\13\10"
  245. write "AT&D3S0=0E0Q0S2=128S25=255\13"
  246. matchread 30
  247. jump 59
  248. !
  249. !  Now that the modem hardware & flow control parameters are set, make sure any 
  250. !  protocol negotiation is disabled, and issue any modem specific features 
  251. !  here.  Make sure that MNP4/V.42, and MNP5-10/V.42bis negotiations are 
  252. !  disabled.  By the way, some V.32/V.32bis modems have an option to disable 
  253. !  Trellis error control,  which is part of the physical layer modulation.  
  254. !  This is not the same as MNP/V.42, and you do not want to disable it!
  255. !
  256. !  Make sure that the modem is configured so it does NOT require error control 
  257. !  to complete a link.  ARA 1.0 does all error correction/data compression in 
  258. !  software.  All ARA wants is the fastest raw data pipe it can get.  If the 
  259. !  script spends time trying to negotiate some error control, the modems and/or 
  260. !  Remote Access may time out.
  261. !
  262. !  Also note the S38 configuration.  It is noted later in the script that it is 
  263. !  desirable to ensure that the modem's buffer has transmitted all of it's 
  264. !  data before it actually hangs the modem up.  This ability appears to be 
  265. !  implemented on a lot of modems.
  266. !
  267. !  This set of commands is going to be implemented differently on different
  268. !  vendors V.32bis modems.  In this example, Telebit uses S registers.
  269. !  Other modems may use S registers (but different registers), or \
  270. !  commands, or % commands; you get the idea.  (Did I mention that you
  271. !  really, really want to have your modem manual handy?)
  272. !
  273. !  It is important that the modem is configured so that it returns
  274. !  the connected speed, NOT the DTE speed.  The script need to know what the 
  275. !  real line speed is in order to set ARA's internal timers.  Some
  276. !  modems don't have the option to display the line speed.  In that case the 
  277. !  performance of the connection may not be optimal.
  278. !
  279. ! Next, disable MNP and error control, set the delay before disconnect,
  280. ! and extended result codes (CTS/RTS flow control and internal DTE<->DCE
  281. ! buffering was set when &F9 was issued , so it is not necessary to do it 
  282. ! again).
  283. !
  284. ! S180=0 - Turn off all error detection/correction (ARA does MNP and
  285. !          compression itself.  It needs these turned off in the modem).
  286. ! S38=255  - Wait until the modem's buffer is clear OR the other modem 
  287. !            disconnects after an ATH is issued before dropping the line.
  288. !            This is done to ensure that all any data in the modem's buffer
  289. !            has been transmitted to the remote modem before it disconnects.
  290. !            If the remote connection does not receive the
  291. !            disconnect packet (usually the last one sent) it could take
  292. !            up to 45 seconds for the remote connection to timeout and
  293. !            disconnect.
  294. ! S50=254  - Attempt to connect at closest current DTE speed (Turbo-PEP
  295. !            excluded).  This allows the modem to connect at the highest
  296. !            possible rate without attempting Turbo-PEP.
  297. ! S51=252  - Autobaud, no type-ahead permitted.  This sets the modem
  298. !            to autobaud at the last speed the Macintosh communicated
  299. !            to the modem.  If this is not done, or is set to autobaud
  300. !            at a fixed DTE speed, the @HANGUP section can lose communication
  301. !            with the modem.
  302. ! X2 - Issue extended result codes.  This will display busy, connect XXX, etc.
  303. !      X2 will say "CONNECT XXX"  Where XXX is the line speed (as opposed to
  304. !      DTE speed).  This is so ARA can determine what speed the modems are 
  305. !      communicating at for timing.
  306. !
  307. !
  308. @LABEL 5
  309. pause 5
  310. matchclr
  311. matchstr 1 6 "OK\13\10"
  312. write "ATS180=0S38=255S50=254S51=252X2\13"
  313. matchread 30
  314. jump 59
  315. !
  316. !  The modem should now be properly configured.  Now check to see if the user 
  317. !  has turned off the modem speaker.  If they have, send an additional command 
  318. !  to turn it off.
  319. !
  320. ! If speaker on flag is true, jump to label 8.  Otherwise turn off the speaker.
  321. !
  322. @LABEL 6
  323. ifstr 2 8 "1"
  324. pause 5
  325. matchclr
  326. matchstr 1 8 "OK\13\10"
  327. write "ATM0\13"
  328. matchread 30
  329. jump 59
  330. !
  331. ! The modem is ready so enable answering, or originate a call.
  332. !
  333. @LABEL 8
  334. pause 5
  335. ifANSWER 30
  336. note "Dialing ^1" 3
  337. write "ATDT^1\13"
  338. !
  339. !  Be aware that different modems will have different format strings 
  340. !  to return connection results.  You need to understand the different possible 
  341. !  strings and set this area (and then answer area at label 31) to the 
  342. !  appropriate value.  Also, remember that the modem was configured to return 
  343. !  the connect speed if possible (The X2 command up at label 5).  It's also 
  344. !  useful if the modem can return busy, no dialtone, etc. since the script will 
  345. !  be able to exit quicker and let the user know what is going on.
  346. !
  347. !  Also note that the script waits at the bottom of label 9 for a 70 seconds, 
  348. !  rather then looping around.  Why?  Well, if the script re-issues the dial 
  349. !  command too soon, that would cause the modem to hang up.  At this point the 
  350. !  script should wait a reasonable amount of time for one of these strings to 
  351. !  return from the modem and take the appropriate action.
  352. !
  353. @LABEL 9
  354. matchstr 1  11 "CONNECT 1200\13\10"
  355. matchstr 2  12 "CONNECT 2400\13\10"
  356. matchstr 3  13 "CONNECT 4800\13\10"
  357. matchstr 4  19 "CONNECT 7200\13\10"
  358. matchstr 5  14 "CONNECT 9600\13\10"
  359. matchstr 6  20 "CONNECT 12000\13\10"
  360. matchstr 7  18 "CONNECT 14400\13\10"
  361. matchstr 8  50 "NO CARRIER\13\10"
  362. matchstr 9  50 "ERROR\13\10"
  363. matchstr 10 52 "NO DIALTONE\13\10"
  364. matchstr 11 53 "BUSY\13\10"
  365. matchstr 12 54 "NO ANSWER\13\10"
  366. matchread 700
  367. jump 59
  368. !
  369. !  All that is done for different connect speeds is to issue a 
  370. !  "CommunicatingAt" command.  Remember, the interface speed is locked
  371. !  to 19,200 bps so the script doesn't want to reset the serial speed after it 
  372. !  connects.
  373. !
  374. !  CommunicatingAt tells ARA what the actual line speed is so that it
  375. !  can set it's timers appropriately.  I guess performance would be
  376. !  sub-optimal if this is not set...
  377. !
  378. @LABEL 11
  379. note "Communicating at 1200 bps." 2
  380. CommunicatingAt 1200
  381. jump 15
  382. !
  383. @LABEL 12
  384. note "Communicating at 2400 bps." 2
  385. CommunicatingAt 2400
  386. jump 15
  387. !
  388. @LABEL 13
  389. note "Communicating at 4800 bps." 2
  390. CommunicatingAt 4800
  391. jump 15
  392. !
  393. @LABEL 19
  394. note "Communicating at 7200 bps." 2
  395. CommunicatingAt 7200
  396. jump 15
  397. !
  398. @LABEL 14
  399. note "Communicating at 9600 bps." 2
  400. CommunicatingAt 9600
  401. jump 15
  402. !
  403. @LABEL 20
  404. note "Communicating at 12000 bps." 2
  405. CommunicatingAt 12000
  406. jump 15
  407. !
  408. @LABEL 18
  409. note "Communicating at 14400 bps." 2
  410. CommunicatingAt 14400
  411. jump 15
  412. !
  413. ! Set RTS/CTS handshaking ON in the serial port (CTS is the 2nd 1 in the
  414. ! HSReset command below, and RTS is the 6th 1 in the HSReset command below).
  415. !
  416. !  The modems have connected, so enable hardware handshaking on the serial 
  417. !  port.  If the script is answering a telephone call, just exit right away and 
  418. !  starting communicating.  If the script is dialing out, give the other end 
  419. !  some time (3 seconds in this example) to get ready to talk to this modem.
  420. !  Exit 0 tells Remote Access that the script was successful in attempting a
  421. !  connection.
  422. !
  423. @LABEL 15
  424. HSReset 0 1 0 0 0 1 
  425. ifANSWER 16
  426. pause 30
  427. @LABEL 16
  428. exit 0
  429. !
  430. !  Notice that the @ANSWER label is actually a comment here, and that 
  431. !  @ORIGINATE and @ANSWER start at the same place.  What's the point of having 
  432. !  separate entry points if they are not used?  Well, in the case of modems, 
  433. !  when they dial out or wait for a call, the setup is usually the same.  One 
  434. !  reason for separate entry points is when the script is not directly talking 
  435. !  to a modem, but maybe to a PBX or terminal server.  It may be necessary to 
  436. !  have completely different configuration for answering and originating 
  437. !  connections.
  438. !
  439. ! @ANSWER
  440. ! Set up the modem to answer the telephone.
  441. !
  442. ! Q0 - Return result codes for both local and remote modems.  &F9 sets this
  443. !      only for standalone modems, so it has to be done here in case the
  444. !      script is being used with a rackmount modem.  It appears that
  445. !      certain revisions of T3000 firmware don't set this correctly,
  446. !      so do it here as well as label 4 just to make sure things work.
  447. !
  448. !
  449. @LABEL 30
  450. matchclr
  451. matchstr 1 31 "OK\13\10"
  452. write "ATS0=1Q0\13"
  453. matchread 30
  454. jump 59
  455. !
  456. !  What is userhook 1 doing in label 32?  Here's the idea:  Either this script 
  457. !  controls a server that is waiting to answer the telephone, or it's waiting 
  458. !  for a callback to a connection that was initiated.  AppleTalk Remote Access 
  459. !  does a "passive" listen on the serial port (via the Serial Port Arbitrator) 
  460. !  so that other communications applications can use the serial port when ARA 
  461. !  is not using it.  When a call comes in for a server or callback, there
  462. !  will be about 5-14 seconds while the modems negotiate the connection.
  463. !  What would happen if a communications application on this Macintosh 
  464. !  wanted to use the serial port during that time?  Both connections
  465. !  would fail.  The userhook 1 command tells ARA to mark the serial port in 
  466. !  use.  When that happens, applications that want to use the serial port will 
  467. !  be told it's busy, and the incoming connection can complete.  With that in 
  468. !  mind, the strategy below is:  When the modem receives a ring, jump to label 
  469. !  32, issue the userhook 1 command, then jump back up to label 31, wait for 
  470. !  the connect result code and continue processing the script.
  471. !
  472. @LABEL 31
  473. matchstr 1  32 "RING\13\10"
  474. matchstr 2  11 "CONNECT 1200\13\10"
  475. matchstr 3  12 "CONNECT 2400\13\10"
  476. matchstr 4  13 "CONNECT 4800\13\10"
  477. matchstr 5  19 "CONNECT 7200\13\10"
  478. matchstr 6  14 "CONNECT 9600\13\10"
  479. matchstr 7  20 "CONNECT 12000\13\10"
  480. matchstr 8  18 "CONNECT 14400\13\10"
  481. matchstr 9  50 "NO CARRIER\13\10"
  482. matchstr 10 50 "ERROR\13\10"
  483. matchstr 11 52 "NO DIALTONE\13\10"
  484. matchstr 12 53 "BUSY\13\10"
  485. matchstr 13 54 "NO ANSWER\13\10"
  486. matchread 700
  487. jump 31
  488. !
  489. @LABEL 32
  490. userhook 1
  491. note "Answering phone..." 2
  492. jump 31
  493. !
  494. !  These are some common error messages when the line is busy, no dialtone, 
  495. !  etc. They are documented in the Scripting Language Guide.  When the script 
  496. !  exits with a code other than zero, Remote Access knows that the connection 
  497. !  failed, and will inform the user with a dialog.
  498. !
  499. ! 50: error messages
  500. !
  501. @LABEL 50
  502. exit -6021
  503. !
  504. @LABEL 52
  505. exit -6020
  506. !
  507. @LABEL 53
  508. exit -6022
  509. !
  510. @LABEL 54
  511. exit -6023
  512. !
  513. @LABEL 59
  514. exit -6019
  515. !
  516. ! Hang up the modem
  517. ! Note:  Why try to enter command mode and hang up the line with ATH, when 
  518. !        de-asserting DTR will always work, and it is used as a last resort 
  519. !        anyway?  If DTR is used immediately,  the modem will hang up 
  520. !        immediately.  This can have the ill effect of hanging up before all 
  521. !        the data in the modem's internal transmit buffer has been sent.
  522. !        It is very desirable to have the last byte of data sent make
  523. !        it out of the modem and across the phone line.  Typically,
  524. !        the last packet sent is the disconnect packet, and if
  525. !        the other side misses this packet, it may have to wait up to 45 
  526. !        seconds to hang up.
  527. !
  528. @HANGUP
  529. @LABEL 60
  530. settries 0
  531. HSReset 0 0 0 0 0 0 
  532. @LABEL 61
  533. !
  534. !  Here's the basic logic for hanging up: If the modem can be configured
  535. !  to enter command mode when it receives a short break, send a short
  536. !  break.  Send an ATH to hang the line up (and if possible up in the 
  537. !  configuration, set the modem to attempt to send all the data in the 
  538. !  buffer before it disconnects).  If that fails, it must still be on
  539. !  line, so send the escape sequence to try to drop into command mode.
  540. !  Don't issue a short break again since it did not work the first time.
  541. !  If that fails, de-assert DTR which should force the modem to hang up
  542. !  and reset.  (make sure the cable is wired properly for this option!).
  543. !  NOTE that the TIES escape sequence was disabled up in labels 1 & 4.
  544. !  The script depends on the ability of the modem to enter command mode
  545. !  via a short break or de-asserting DTR.  If either of these fail, the
  546. !  modem will probably have to be power cycled.  If a different modem
  547. !  will not go into command mode without using an escape sequence (either
  548. !  the Hayes guard time or TIES), make sure labels 1 & 4 are configured
  549. !  accordingly.
  550. !
  551. !  How was this sequence determined?  Trial and error.  Different vendors 
  552. !  modems behave differently when disconnecting.  Some modems will not enter 
  553. !  command modem during a disconnect, and the only option is to de-assert DTR 
  554. !  to force them to reset.  That's why DTR resets the modem instead of just
  555. !  disconnecting it!  Experiment with this sequence to make it function, but it 
  556. !  should work with the majority of the modems available.
  557. !
  558. ! Now, since the Telebit modems will drop into command mode when they receive
  559. ! a short break (S61=1), issue one here.  This will speed up the disconnect
  560. ! sequence by about 5-6 seconds.  Then continue on with normal AT disconnect
  561. ! processing.
  562. !
  563. Sbreak
  564. !
  565. ! Pause for the result code "OK" to return from the modem, then flush it from
  566. ! the input buffer.  Wait just a brief amount of time (1/2 second in this case)
  567. ! so the modem will be ready to accept the ATH command.  Pause 1 actually seems
  568. ! to work ok, but it's set to 5 just to be safe.
  569. !
  570. pause 1
  571. flush
  572. pause 5
  573. matchclr
  574. matchstr 1 63 "NO CARRIER\13\10"
  575. matchstr 2 63 "OK\13\10"
  576. matchstr 3 63 "ERROR\13\10"
  577. write "ATH\13"
  578. matchread 30
  579. inctries
  580. iftries 3 63
  581. !
  582. ! No response, so try de-asserting DTR.  If this script is going to be
  583. ! modified to use either the Hayes guard time or TIES escape sequence,
  584. ! this is the point where it would be attempted.  The commands are left in
  585. ! the script for that possibility, but they are commented out for the T3000
  586. ! and WorldBlazer.  Also note that LABEL 62 is only called by the matchstr
  587. ! below, so it is commented out as well.
  588. !
  589. !matchclr
  590. !matchstr 1 62 "OK\13\10"
  591. !write "+++"
  592. !matchread 15
  593. !
  594. ! No response, so try de-asserting DTR.  Note that the script de-asserts
  595. ! DTR for 3 seconds, since the modem is configured for DTR to be
  596. ! de-asserted for 2.55 seconds before accepting it.
  597. !
  598. DTRClear
  599. pause 30
  600. DTRSet
  601. jump 61
  602. !
  603. !@LABEL 62
  604. !!
  605. !! Pause 1 second to ensure we meet the escape time delay, or
  606. !! to allow the modem time to be ready for the next command.
  607. !!
  608. !pause 10
  609. !flush
  610. !matchclr
  611. !matchstr 1 63 "OK\13\10"
  612. !matchstr 2 63 "NO CARRIER\13\10"
  613. !matchstr 3 63 "ERROR\13\10"
  614. !write "ATH\13"
  615. !matchread 30
  616. !jump 61
  617. !
  618. !  Now that the modems have disconnected, and the script has possibly reset the 
  619. !  modem, restore the factory settings.  Remember, the script may have hung up 
  620. !  the modem in order to get ready for a callback, or it wants to get ready to 
  621. !  wait to answer a call again.
  622. !
  623. ! Recall the factory settings.  Use &F9 again (see note at top of script)
  624. !
  625. @LABEL 63
  626. Sbreak
  627. Pause 1
  628. matchclr
  629. matchstr 1 64 "OK\13\10"
  630. write "AT&F9\13"
  631. matchread 40
  632. !
  633. !  Now turn off auto answer if it was turned on to answer a call.  If this 
  634. !  script controls a server, the @ANSWER sequence will be called by ARA.
  635. !  One other thing to watch out for here is that some modems expect to
  636. !  talk to the DTE at the last connected speed.  If this is a V.32bis 
  637. !  modem and it just finished a connection with a 2400 baud modem, it
  638. !  doesn't necessarily want to talk at 2400 the next time!  Some modems
  639. !  don't exhibit this behavior, so play with it and see what happens.  Finally, 
  640. !  since it successfully hung up,  exit the script with a result code of 0 to 
  641. !  let Remote Access know everything worked.
  642. !
  643. ! Turn off auto answer, set S51 so modem will check interface
  644. ! speed on next connection.  If this is not done, the modem
  645. ! will not try to autobaud, with the result being it exits the 
  646. ! script with an error.
  647. ! S51=252  - Autobaud, no type-ahead permitted.  This sets the modem
  648. !            to autobaud at the last speed the Macintosh communicated
  649. !            to the modem.  If this is not done, or is set to autobaud
  650. !            at a fixed DTE speed, the @HANGUP section can lose communication
  651. !            with the modem.
  652. ! S0=0 - Don't try to answer the phone
  653. !
  654. @LABEL 64
  655. matchclr
  656. matchstr 1 65 "OK\13\10"
  657. write "ATS51=252S0=0\13"
  658. matchread 40
  659. jump 59
  660. !
  661. @LABEL 65
  662. exit 0
  663.